package com.jlpay.openapi.demo.trans.common;

import com.jlpay.open.jlpay.sdk.java.model.trans.common.request.PreAuthRevokeRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.common.response.PreAuthRevokeResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class PreAuthRevokeService {
    private static final Logger LOGGER = LoggerFactory.getLogger(PreAuthRevokeService.class);

    public static void main(String[] args) {
        PreAuthRevokeRequest preAuthRevokeRequest = buildPreAuthRevokeRequest();
        PreAuthRevokeResponse preAuthRevokeResponse = JlpayOpenApiService.openMerchService()
                .post(preAuthRevokeRequest, PreAuthRevokeResponse.class);
        LOGGER.info("预授权撤销响应:{}", JsonUtils.toString(preAuthRevokeResponse));
    }

    private static PreAuthRevokeRequest buildPreAuthRevokeRequest() {
        PreAuthRevokeRequest preAuthRevokeRequest = new PreAuthRevokeRequest();

        preAuthRevokeRequest.setMchId("849584358120018");
        preAuthRevokeRequest.setTermNo("60131234");
        preAuthRevokeRequest.setPayType("wxpay");
        preAuthRevokeRequest.setOutTradeNo("ld201911023465529");
        preAuthRevokeRequest.setOriOutTradeNo("ld2019102216465525");
        preAuthRevokeRequest.setOriTransactionId("80011557201909171853011568");
        preAuthRevokeRequest.setGuaranteeAuthCode("134965710109584780");
        preAuthRevokeRequest.setTotalFee("1");
        preAuthRevokeRequest.setRemark("该订单物流请走顺丰快递");
        preAuthRevokeRequest.setDeviceInfo("N50007A8890");
        preAuthRevokeRequest.setMchCreateIp("123.12.12.123");
        preAuthRevokeRequest.setTransAddress("深圳市南山区科技二路10号");
        preAuthRevokeRequest.setAreaCode("4403");
        preAuthRevokeRequest.setLongitude("116.078631");
        preAuthRevokeRequest.setLatitude("39.71274");

        return preAuthRevokeRequest;
    }
}
